package com.hadwinling.blog.mapper;

import com.hadwinling.blog.entity.Comment;
import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;import java.util.List;

/**
 * @author HadwinLing
 * @version V1.0
 * @Package com.hadwinling.blog.mapper
 * @date 2020/8/24 10:46
 */
@Mapper
public interface CommentMapper {
    /**
     * delete by primary key
     *
     * @param id primaryKey
     * @return deleteCount
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * insert record to table
     *
     * @param record the record
     * @return insert count
     */
    int insert(Comment record);

    /**
     * insert record to table selective
     *
     * @param record the record
     * @return insert count
     */
    int insertSelective(Comment record);

    /**
     * select by primary key
     *
     * @param id primary key
     * @return object by primary key
     */
    Comment selectByPrimaryKey(Integer id);

    /**
     * update record selective
     *
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKeySelective(Comment record);

    /**
     * update record
     *
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKey(Comment record);

    //根据某个 文章id查询所有评论
    List<Comment> selectAllByArticleidOrderByCreatetimeDesc(@Param("articleid")Integer articleid);

    //根据parentcommentid 查询评论
    List<Comment> selectAllByParentcommentidOrderByCreatetimeDesc(@Param("parentcommentid")Integer parentcommentid);

    int updateCommentcountByParentcommentid(@Param("parentcommentid")Integer parentcommentid);





}